#include "ADC1.h"
extern float Ia,Ib,Ic;
ABC_Def i;
AlphaBeta_Def ab;
DQ_Def dq;
extern FOC_DEF foc;
void ADC_init(void)
{
	HAL_TIM_Base_Start(&htim1);
	__HAL_ADC_ENABLE_IT(&hadc1, ADC_IT_JEOC);
	HAL_ADCEx_InjectedStart(&hadc1);
	
//	__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_1,PWM_PERIOD-1);
}	


void get_AD(void)
{
	uint16_t AD_power,AD_U,AD_V,AD_W;
	AD_power=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_1);
	AD_U=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_2);
	AD_V=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_3);
	AD_W=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_4);
	vofa_FireWater_output(AD_power,AD_U,AD_V);
}

void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	if(hadc->Instance == ADC1)
	{

		
;	}

}
void first_get(void)
{
	float i,ia,ib,ic,ia_sum,ib_sum,ic_sum;
	for(i=0;i<1000;i++)
	{
		ia=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_1);
		ib=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_2);
		ic=HAL_ADCEx_InjectedGetValue(&hadc1,ADC_INJECTED_RANK_3);
		ia_sum=ia+ia_sum;
		ib_sum=ib+ib_sum;
		ic_sum=ic+ic_sum;
		HAL_Delay(1);
	}
	Ia=ia_sum/1000;
	Ib=ib_sum/1000;
	Ic=ic_sum/1000;
	
}
//void i_init(void)
//{
//	
//}
